Repository navigation
feat: show a busy session's queued messages in the preview - #385
Merged
Merged
Conversation
A message that reaches a session mid-turn (typed in its tab, sent from ccs, or from another session) waits in Claude Code's queue, which its tab shows as "⎿ Queued" until Claude takes it in. The preview now shows the same at its end, while the session is busy or waiting: each message, then a dim "⎿ Queued". Once taken in it is an ordinary message above. The queue comes from Claude Code's queue-operation lines: enqueue adds a message; remove, popAll and popOne drop one by content; a dequeue names none, so the user line or queued_command that follows is the message taken in. Only messages enqueued since the last turn end count, since a turn that ends with messages queued takes them in at once. Queued messages aren't messages: counts, unread, done, WHEN and the search ignore them. ccs sessions lists them as queued: lines (queued in --json). Codex rollouts record no queue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opus 5.5 ✨
What changes
While a session is mid-turn, the messages it has queued and not taken in yet now show at the end of its preview, as Claude Code's own tab shows them: the message, then a dim
⎿ Queued. That covers messages typed in its tab, sent from ccs, and sent by another session (drawn underFrom <name>). Once Claude takes one in, it leaves the queue and shows as an ordinary message above. Claude Code'sctrl+enter to send nowis left off, since only its tab has that key.ccs sessionslists them too, asqueued:lines (queuedin--json), solist_sessionslive lines get them as well.read_sessiondoesn't: it has no live status to tell a stale queue from a real one, and its offsets count entries, so it isn't a small change.Queued messages aren't messages: counts, unread, done, WHEN and the search ignore them (not searchable: the search text has to stay identical between full and incremental parses, so that isn't simple).
What Claude Code writes
Read from the 2.1.330 binary (the queue module that writes
queue-operationlines) and checked against real transcripts, read-only:enqueueremovereasonabsorbed_mid_turn(then aqueued_commandattachment with its text),delivered_to_agent,cleared_on_cancel,dropped_by_hookpopAll/popOnedequeueA
dequeuenames no message, and Claude Code picks by priority (now,next,later), not strictly first in first out, so ccs matches by content instead: a remove or pop by its content, and otherwise the user line orqueued_commandthe message became. A cross-session message is taken in wrapped differently from how it was queued (an "Another Claude session sent a message:" line,hop-chaindropped), so matching uses its body with whitespace collapsed, compared exactly. A substring match would let a short message likeokbe dropped by an unrelated line. Aqueued_commandafter anabsorbed_mid_turnremove is that message's copy, so it drops nothing, and the same text queued twice keeps the second.Only messages enqueued after the last turn end are shown, and only while the session is busy or waiting: a turn that ends with messages queued takes them in at once, so anything older is one ccs never saw taken in.
Measured on this machine's transcripts: 1,128 have queue records, with about 79k enqueues, 49k dequeues and 30k removes. With exact matching, 70 messages are never seen taken in, mostly slash commands and
!commands, which show up as their output rather than as their text. After the turn-end filter, 3 remain across all transcripts, and those would show only if their session were running mid-turn.Codex: its rollouts record only
task_started,task_completeandturn_aborted, and nothing for a queued message, so Codex sessions show none.Untrusted text
A queued message's text is cleaned where it enters (
noteEnqueued), and so isQueued, the list kept for delivery status.TestUntrustedTextIsCleanedWhereItEntersnow enqueues a typed message and a cross-session one carrying the poison, and checks the drawn preview andPlain(). The match keys stay raw because they're compared, never drawn.Tests
internal/transcript/queue_test.go: a message typed mid-turn, the same text queued twice, dequeue then a cross-session user line, pop and remove, harness text skipped, the turn-end filter,Plain, and a removal never writing over a copy handed out earlierTestPreviewShowsQueuedMessages: drawn while busy, hidden while idle, and moved into the conversation once taken inTestSessionRowQueued:ccs sessionsrowsNo demo re-record: this adds rows to the preview, not a pane or layout.
🤖 Generated with Claude Code